using UnityEngine;
using System.Collections;

public class MoveScript : MonoBehaviour {
	
	public float m_Speed = 3.0f;
	public float m_RotationSpeed = 200.0f;
	float m_CurSpeed = 0.0f;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		// Rotate around y-axis
		float newRotation = Input.GetAxis("Horizontal") * m_RotationSpeed;
		transform.Rotate(0, newRotation * Time.deltaTime, 0);

		// Calculate speed
		float newSpeed = Input.GetAxis("Vertical") * m_Speed;
		if (Input.GetKey("left shift"))
			newSpeed *= 1.5f;

		// Move the controller
		CharacterController controller = (CharacterController)GetComponent ("CharacterController");

        Vector3 forward = transform.TransformDirection(Vector3.forward);
		controller.SimpleMove(forward * newSpeed);
		
		// Update the speed in the Animation script
		SendMessage("SetCurrentSpeed", newSpeed, SendMessageOptions.DontRequireReceiver);
		SendMessage("SetCurrentLean", Input.GetAxis("Horizontal"), SendMessageOptions.DontRequireReceiver);
	}
	
	void onJump()
	{
		print("jump");
	}
}
